package cn.itcast.shop.util;

import java.util.List;

/**
 * 分页类的封装
 */
public class PageBean<T> {

    private int page ;  //当前页数
    private int totalCount;    //总记录数
    private int totalPage;  //总页数
    private int limit;  //每页显示的记录数
    private int beginIndex;     //每页的起始记录
    private int endIndex;   //每页的结束记录

    public int getBeginIndex() {
        return (page - 1) * limit ;
    }

    public void setBeginIndex(int beginIndex) {
        this.beginIndex = beginIndex;
    }

    public int getEndIndex() {
        return page * limit;
    }

    public void setEndIndex(int endIndex) {
        this.endIndex = endIndex;
    }

    private List<T> list;

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getTotalCount() {
        return totalCount;
    }

    public void setTotalCount(int totalCount) {
        this.totalCount = totalCount;
    }

    public int getTotalPage() {
        return (int)Math.ceil((double)totalCount/(double)limit) ;
    }

    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }

    public int getLimit() {
        return limit;
    }

    public void setLimit(int limit) {
        this.limit = limit;
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }
}
